package com.authorityManagement.exception;

import com.authorityManagement.util.resultUtil.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class UnifiedExceptionHandler {

        @ExceptionHandler(Exception.class)
        public R exception(Exception e) {
            R fail = R.fail();
            fail.setMessage(e.getMessage());
            log.error(e.getMessage());
            return fail;
        }

        @ExceptionHandler(CustomerExceptionHandler.class)
        public R SQLException(Exception e){
            R fail = R.fail();
            fail.setMessage(e.getMessage());
            log.error(e.getMessage());
            return fail;
        }
    }